<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>订阅推送事件</title>
</head>
<body>
  <script>
    (async () => {
      const registration = await navigator.serviceWorker.register('./27_4_11_3_serviceWorker.js');
      registration.pushManager.subscribe({
        applicationServerKey: '<public-key>',  // 来自服务器的公钥
        userVisibleOnly: true
      });
    })();
  </script>
</body>
</html>